<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<title>确认订单</title>
<link rel="stylesheet" href="../css/common/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" href="../css/common/weui.min.css">
<link rel="stylesheet" href="../css/common/jquery-weui.min.css">
<link rel="stylesheet" href="../css/confrimOrder.css">

<script src="../js/common/jquery-2.0.0.js"></script>
<script src="../js/common/jquery.mobile-1.4.5.js"></script>
<script src="../js/ajax_req.js"></script>
<script src="../js/api.js"></script>

<!--
	作者：wyy8@live.cn
	时间：2017-06-06
	描述：微信
-->
<script type="application/javascript" src="../js/common/jweixin-1.0.0.js"></script>
<script type="application/javascript" src="../js/common/jquery-weui.min.js"></script>
<!--模板-->
<script type="application/javascript" src="../plugins/jquery-tmpl/jquery.tmpl.js"></script>
<script type="application/javascript" src="../plugins/jquery-tmpl/jquery-jtemplates.js"></script>
<script type="application/javascript" src="tmpl/confirmOrder.js"></script>
</head>
<body>
<div data-role="page">
	<div class="address_content">
		<table style="width:100%;">
			<tbody>
				<tr>
					<td></td>
					<td colspan="2">
						<div class="shouhuoren">
							<span class="address_shouhuoren">收货人:</span>
							<span id="address-people-div"></span>
							<span id="address-people-tel"></span>
						</div>
					</td>
				</tr>
				<tr height="8"></tr>
				<tr>
					<td width="38px" align="center">
						<img src="../image/dingwei@2x.png" width="13px" height="17px" style="margin-top: 3px;"/></td>
					<td id="address-span" >
						<span>收货地址:</span>
					</td>
					<td id="address-more" width="20px" align="center">
						<img src="../image/more.png" width="9px" height="16px" style="margin-top: 3px;"/>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
	
	<div class="beijing"></div>
	
	<div id="confirm-order-div"></div>
	
	<div data-role="popup" id="popup">
		<p></p>
	</div>
</div>
</body>
<script>
	//格式sku=1-2-3,1-2-3
	var sku_list = []
	var orderdata = {}
	//login(window.location.href)
	var sku = getQueryString("sku")
	if(sku != null){
		var items = sku.split(',')
		if(items != null){
			for(var i=0; i<items.length; i++){
				var arr = items[i].split('-')
				if(arr != null && arr.length == 3){
					sku_list.push({product_id:arr[0], sku_id:arr[1], quantity:arr[2]})
				}
			}
		}
	}
	ajax(api.setOrder, {product_sku: JSON.stringify(sku_list)}, function(data){
		var adid = getQueryString("adid")
		if(adid != null){
			ajax(api.getReceiver, {id:adid}, function(item){
				$("#address-people-div").append(item.name)
				$("#address-people-tel").html(item.mobile)
				$("#address-span").append(item.area_path+item.address)
				data.shopReceiver = item
				orderdata = data
			})
		}else{
			if(data.shopReceiver == null || data.shopReceiver.id == null || data.shopReceiver.id == 0){
				confirm("您还没有设置收货地址，请点击这里设置？", "确认设置?", function() {
		          window.location.href = "myAddress.html?url="+window.location.href
		        }, function() {
		          window.history.go(-1)
		        });
			}
			$("#address-people-div").append(data.shopReceiver.name)
			$("#address-people-tel").html(data.shopReceiver.mobile)
			$("#address-span").append(data.shopReceiver.area_path+data.shopReceiver.address)
			orderdata = data
		}
		
		
		$("#confirm-order-div").setTemplateURL('tmpl/confirmOrderTmpl.html');
	    $("#confirm-order-div").setParam("width", window.screen.width); 
		$("#confirm-order-div").processTemplate(data);
	})
	
	//点击添加地址事件
	$("#address-more").on("click", function(){
		window.location.href = "myAddress.html?url="+window.location.href
	})
	
	$(function(){
		//$("#select_free_pay-button").removeClass("ui-btn")
		//$("#select_free_pay-button").removeClass("ui-icon-carat-d")
		$("#select_free_pay-button").removeClass("ui-btn-icon-right")
		//$("#select_free_pay-button").removeClass("ui-corner-all")
		//$("#select_free_pay-button").removeClass("ui-shadow")
	})
	
</script>
</html>